<%@ page import="java.util.List,
                 com.actimind.actitime.reports.OvertimeReportForm"%>
<%@ taglib uri="/WEB-INF/at.tld" prefix="at" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
    <title><bean:write name="title-prefix" scope="application"/> Overtime Report</title>
    <link rel="stylesheet" href="../css/at.css" type="text/css">
    <script language="JavaScript" src="../js/at.js"></script>
    <script language="JavaScript" src="../js/calendar.js?r=1"></script>
<script language="Javascript">
function checkFields(f)
{
    if(f.allUsers && f.allUsers[1].checked)
    {
        var b = false;
        for(i = 0; i < f.selectedUserIds.options.length; i++)
        {
            if(f.selectedUserIds.options[i].selected)
                b = true;
        }
        if(!b)
        {
            window.alert('Choose at least one person or select option "All Staff"');
            return false;
        }
    }
    if(fromDate > toDate)
    {
        window.alert('"From" date should be before "To" date');
        return false;
    }
    return true;
}
</script>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" onLoad="document.forms[0].autocomplete='off';">

<jsp:include page="../top.jsp" flush="false">
    <jsp:param name="pageSection" value="reports"/>
    <jsp:param name="pageAction" value="overtime"/>
</jsp:include>

<at:form action="/reports/overtime" method="post" onsubmit="return checkFields(this);">
<html:hidden property="pageAction" value=""/>
<html:hidden property="submitted" value="true"/>

<bean:define id="form" name="OvertimeReportForm" type="com.actimind.actitime.reports.OvertimeReportForm" />
<bean:define id="users" property="users" name="OvertimeReportForm"/>

<table width="770" align="center" cellspacing="0" cellpadding="4" border="0">
<tr>
    <td colspan="4" class="pagetitle" valign="top">Overtime Report</td>
</tr>
<tr>
    <td colspan="4"><at:errors/></td>
</tr>
<logic:notEmpty name="users">
<tr>
    <td nowrap class="formblocktitle">STEP 1.</td>
    <td nowrap class="formblocktitle">CHOOSE STAFF</td>
    <td nowrap class="formblocktitle">STEP 2.</td>
    <td nowrap class="formblocktitle">CHOOSE REPORT FORMAT</td>
</tr>
<tr>
    <td rowspan="8"></td>
    <td valign="top" rowspan="8">
        <table width="80%" cellspacing="0" cellpadding="2" border="0">
        <tr>
            <td width="3%" class="text"><html:radio property="allUsers" value="true" onclick="setOptionsState(this.form.selectedUserIds, false);"/></td>
            <td class="text" nowrap>All Staff with Overtime Tracking Enabled</td>
        </tr>
        <tr>
            <td class="text" valign="top"><html:radio property="allUsers" value="false"/></td>
            <td class="text">Selected Staff:<br>
            <span class="smallcomment">The list below includes users having overtime tracking enabled.</span>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <at:select multiple="true" property="selectedUserIds" size="21" onchange="this.form.allUsers[1].checked = true" style="width: 180px" width="180" maxlength="27">
                    <at:options collection="users" property="id" labelProperty="formattedNameWithStatus"/>
                </at:select>
            </td>
        </tr>
        </table>
    </td>
    <td></td>
    <td valign="top">
        <table width="80%" cellspacing="0" cellpadding="2" border="0">
        <tr>
            <td width="3%" class="text"><html:radio property="reportType" value="<%=OvertimeReportForm.USERS_SUMMARY_REPORT_TYPE%>"/></td>
            <td class="text">Summary by Users</td>
        </tr>
        <tr>
            <td class="text"><html:radio property="reportType" value="<%=OvertimeReportForm.DAILY_SUMMARY_REPORT_TYPE%>"/></td>
            <td class="text">Daily Overtime Information by Users</td>
        </tr>
        </table>
    </td>
</tr>
<tr>
    <td nowrap class="formblocktitle">STEP 3.</td>
    <td class="formblocktitle">SPECIFY DATE RANGE</td>
</tr>
<tr>
    <td class="formblocktitle"></td>
    <td valign="top"><%@include file="date_utils.jsp"%></td>
</tr>
<tr>
    <td colspan="2">&nbsp;</td>
</tr>
<tr>
    <td colspan="2">&nbsp;</td>
</tr>
<tr>
    <td colspan="2">&nbsp;</td>
</tr>
<tr>
    <td colspan="2">&nbsp;</td>
</tr>
<tr>
    <td colspan="2">&nbsp;</td>
</tr>
<tr>
    <td nowrap bgcolor="#E5E5E5" class="formblocktitle">STEP 4.</td>
    <td colspan="3" bgcolor="#E5E5E5">
        <table cellspacing="0" cellpadding="2" border="0" width="100%">
        <tr>
            <td width="40%" align="right"><input type="submit" onclick="this.form.pageAction.value='html'; return true;" value="Generate HTML Report"></td>
            <td class="text" align="center">-- OR --</td>
            <td width="50%" align="left"><input type="submit" onclick="this.form.pageAction.value='csv'; return true;" value="Generate CSV Report"></td>
        </tr>
        </table>
    </td>
</tr>
</logic:notEmpty>
<logic:empty name="users">
<tr>
    <td colspan="4"><span class="errormsg">There are no users having overtime tracking enabled.</span></td>
</tr>
</logic:empty>
</table>


</at:form>

</body>
</html>